import { FormActionType } from '@/components/Form';
import { isNil } from 'lodash-es';
import gloabComponentConfig from '@/settings/gloabComponentConfig';

export const MenuIsButtonOptions = [
  { label: '菜单', value: '0' },
  { label: '按钮', value: '1' },
];
export const menuTypeOptions = [
  { label: '页面', value: '1' },
  { label: '目录', value: '2' },
  { label: '内嵌Iframe', value: '3' },
  { label: '外链跳转', value: '4' },
];
export const handleUpdateSchema = (formActionType: FormActionType, v: string) => {
  if (!isNil(formActionType)) {
    //外链跳转
    if (v == '4') {
      formActionType?.updateSchema({
        field: 'routerName',
        label: '网站地址',
        componentProps: {
          placeholder: '请输入外部网站地址，必须以https://或者http://开头',
        },
        colProps: gloabComponentConfig.responseColProps.fullspan,
      });
    }
    if (v == '2') {
      formActionType?.updateSchema({
        field: 'path',
        label: '路由地址',
        componentProps: {
          placeholder: '请输入目录的路由地址以/开头',
        },
        colProps: gloabComponentConfig.responseColProps.fullspan,
      });
    }
    if (v == '1') {
      formActionType?.updateSchema([
        {
          field: 'path',
          label: '页面URL',
          componentProps: {
            placeholder: '请输入前端项目地址栏地址',
          },
          colProps: gloabComponentConfig.responseColProps.halfspan,
        },
        {
          field: 'routerName',
          label: '组件名称',
          componentProps: {
            placeholder: '请输入组件定义的name，defineOptions中的name',
          },
          colProps: gloabComponentConfig.responseColProps.halfspan,
        },
      ]);
    }
  }
};
